---
sidebar_label: Custom types
sidebar_position: 14
description: Define custom types with the Hasura schema/Metadata API
keywords:
  - hasura
  - docs
  - schema/Metadata API
  - API reference
  - custom types
---

# Schema/Metadata API Reference: Custom Types (Deprecated)

:::caution Deprecation

In versions `v2.0.0` and above, the schema/Metadata API is deprecated in
favour of the [schema API](/api-reference/schema-api/index.mdx) and the
[Metadata API](/api-reference/metadata-api/index.mdx).

Though for backwards compatibility, the schema/Metadata APIs will
continue to function.

:::

## Introduction

**Custom Types** are user-defined GraphQL types which help to define
[Actions](/api-reference/schema-metadata-api/actions.mdx).

## set_custom_types {#schema-metadata-set-custom-types}

`set_custom_types` is used to set user-defined GraphQL types. This API
will replace the given types with existing ones.

```http
POST /v1/query HTTP/1.1
Content-Type: application/json
X-Hasura-Role: admin

{
  "type": "set_custom_types",
  "args": {
    "scalars": [],
    "enums": [],
    "input_objects": [
      {
        "name": "User",
        "fields": [
          {
            "name": "username",
            "type": "String!"
          },
          {
            "name": "password",
            "type": "String!"
          }
        ]
      }
    ],
    "objects": [
      {
        "name": "UserId",
        "fields": [
          {
            "name": "id",
            "type": "Int!"
          }
        ],
        "relationships": [
          {
            "name": "posts",
            "type": "array",
            "remote_table": "post",
            "field_mapping": {
              "id": "user_id"
            }
          }
        ]
      }
    ]
  }
}
```

### Args syntax {#schema-metadata-set-custom-types-syntax}

| Key           | Required | Schema                                                                     | Description                   |
| ------------- | -------- | -------------------------------------------------------------------------- | ----------------------------- |
| input_objects | false    | Array of [InputObjectType](/api-reference/syntax-defs.mdx#inputobjecttype) | Set of GraphQL `Input Object` |
| objects       | false    | Array of [ObjectType](/api-reference/syntax-defs.mdx#objecttype)           | Set of GraphQL `Object`       |
| scalars       | false    | Array of [ScalarType](/api-reference/syntax-defs.mdx#scalartype)           | Set of GraphQL `Scalar`       |
| enums         | false    | Array of [EnumType](/api-reference/syntax-defs.mdx#enumtype)               | Set of GraphQL `Enum`         |
